<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <title>E8NET</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <!-- bootstrap -->
<link href="/Public/Admin/css/bootstrap/bootstrap.css" rel="stylesheet" />
<link href="/Public/Admin/css/bootstrap/bootstrap-responsive.css" rel="stylesheet" />
<link href="/Public/Admin/css/bootstrap/bootstrap-overrides.css" type="text/css" rel="stylesheet" />

<!-- global styles -->
<link rel="stylesheet" type="text/css" href="/Public/Admin/css/layout.css" />
<link rel="stylesheet" type="text/css" href="/Public/Admin/css/elements.css" />
<link rel="stylesheet" type="text/css" href="/Public/Admin/css/icons.css" />

<!-- libraries -->
<link href="/Public/Admin/css/lib/bootstrap-wysihtml5.css" type="text/css" rel="stylesheet" />
<link href="/Public/Admin/css/lib/jquery-ui-1.10.2.custom.css" rel="stylesheet" type="text/css" />
<link href="/Public/Admin/css/lib/font-awesome.css" type="text/css" rel="stylesheet" />
<link href="/Public/Admin/css/lib/morris.css" type="text/css" rel="stylesheet" />
<link href="/Public/Admin/css/popup.css" type="text/css" rel="stylesheet" />



<!-- open sans font -->
<!--<link href='http://fonts.useso.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css' />-->

<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<link href="/Public/Libs/confirm/jquery.confirm.css" type="text/css" rel="stylesheet" />


    <link href="/Public/Admin/css/lib/select2.css" type="text/css" rel="stylesheet" />
    <link rel="stylesheet" href="/Public/Admin/css/compiled/form-showcase.css" type="text/css" media="screen" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>

<!-- navbar -->
<div class="navbar navbar-inverse">
    <div class="navbar-inner">
        <button type="button" class="btn btn-navbar visible-phone" id="menu-toggler">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>

        <a class="brand" href="index.html">
            E8网络工作室管理后台 V1.0
        </a>

        <ul class="nav pull-right">
            <li class="hidden-phone">
                <input class="search" type="text" />
            </li>


            <!-- 消息提醒 -->
            <li class="notification-dropdown hidden-phone">
                <a href="#" class="trigger">
                    <i class="icon-envelope-alt"></i>
                    <span class="count"></span>
                </a>
                <div class="pop-dialog">
                    <div class="pointer right">
                        <div class="arrow"></div>
                        <div class="arrow_border"></div>
                    </div>
                    <div class="body">
                        <a href="#" class="close-icon"><i class="icon-remove-sign"></i></a>
                        <div class="messages">

                        </div>
                    </div>
                </div>
            </li>


            <!-- 个人菜单 -->
            <li class="dropdown">
                <a href="#" class="dropdown-toggle hidden-phone" data-toggle="dropdown">
                    <?php echo ($_SESSION['admin']['tname']); ?>
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a href="<?php echo U('Public/editPersonalInfo');?>">修改个人资料</a></li>
                    <li><a href="<?php echo U('Public/logout');?>">退出登录</a></li>
                </ul>
            </li>

            <!-- 前台首页 -->
            <li class="settings hidden-phone">
                <a href="" role="button">
                    <i class="icon-globe"></i>
                </a>
            </li>
        </ul>
    </div>
</div>
<!-- end navbar -->
<!-- sidebar -->
<div id="sidebar-nav">
    <ul id="dashboard-menu">

        <?php if(is_array($menu)): $i = 0; $__LIST__ = $menu;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$m): $mod = ($i % 2 );++$i;?><li class="<?php echo ($m["active"]); ?>">

                <?php if($m["active"] == 'active'): ?><div class="pointer">
                        <div class="arrow"></div>
                        <div class="arrow_border"></div>
                    </div><?php endif; ?>

                <a <?php if($m["child"] != ''): ?>class="dropdown-toggle"<?php endif; ?>  href="<?php echo ($m["url"]); ?>">
                    <i class="<?php echo ($m["icon"]); ?>"></i>
                    <span><?php echo ($m["text"]); ?></span>
                    <?php if($m["child"] != ''): ?><i class="icon-chevron-down"></i><?php endif; ?>
                </a>

                <?php if($m["child"] != ''): ?><ul class="<?php echo ($m["active"]); ?> submenu">
                        <?php if(is_array($m["child"])): $i = 0; $__LIST__ = $m["child"];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$c): $mod = ($i % 2 );++$i;?><li><a href="<?php echo ($c["url"]); ?>" class="<?php echo ($c["active"]); ?>"><?php echo ($c["text"]); ?></a></li><?php endforeach; endif; else: echo "" ;endif; ?>
                    </ul><?php endif; ?>
            </li><?php endforeach; endif; else: echo "" ;endif; ?>

    </ul>
</div>
<!-- end sidebar -->

<!-- main container -->
<div class="content">


    <div role="breadcrumb">
        <ol class="breadcrumb">
            <li><a href="<?php echo U('Depart/index');?>">学院管理</a> / </li>
            <li class="active">修改班级</li>
        </ol>
    </div>

    <div class="container-fluid">

        <div id="pad-wrapper" class="form-page">
            <div class="row-fluid form-wrapper">
                <!-- left column -->
                <div class="span6 column offset3">
                    <form id="sadmin-form" />
                    <input type="hidden" value="<?php echo ($D["id"]); ?>" name = "id" id = "bj_id">
                    <div class="field-box">
                        <label>二级学院名称:</label>
                        <select style="width:250px" class="select2" id="xy_id"  placeholder="请选择学院名称" onchange="xyChange();">
                            <?php if(is_array($XyList)): foreach($XyList as $key=>$depart_xy): if($depart_xy['id'] == $Zy['f_id']): ?><option value="<?php echo ($depart_xy["id"]); ?>" selected/><?php echo ($depart_xy["name"]); ?>
                                <?php elseif($depart_xy['id'] != $Zy['f_id']): ?>
                                    <option value="<?php echo ($depart_xy["id"]); ?>" /><?php echo ($depart_xy["name"]); endif; endforeach; endif; ?>
                        </select>
                    </div>

                    <div class="field-box" id="mojor_select">
                        <label>专业名称:</label>
                        <select style="width:250px" class="select2"  id = "zySelector">
                            <?php if(is_array($ZyList)): foreach($ZyList as $key=>$depart_zy): if($depart_zy['id'] == $Zy['id']): ?><option value="<?php echo ($depart_zy["id"]); ?>" selected/><?php echo ($depart_zy["name"]); ?>
                                    <?php elseif($depart_zy['id'] != $Zy['id']): ?>
                                    <option value="<?php echo ($depart_zy["id"]); ?>" /><?php echo ($depart_zy["name"]); endif; endforeach; endif; ?>

                        </select>
                    </div>

                    <div class="field-box">
                        <label>班级名称</label>
                        <input class="span8 inline-input" id = "bj_name" name="name" placeholder="请输入班级名称" type="text" value="<?php echo ($D["name"]); ?>"/>
                        <br>
                        <span id="msg" style="display: none; color:darkred">
                            <i class="icon-remove-sign"></i>
                            <small></small>
                        </span>
                    </div>


                    <div class="span6 field-box actions" style="padding-left:360px;">

                        <a href="javascript:edit();" class="btn-flat default">
                            提交表单
                        </a>
                        <a href="<?php echo U('index');?>" class="btn-flat gray">
                            放弃提交
                        </a>
                    </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- end main container -->

<!-- scripts for this page -->
<script src="/Public/Admin/js/wysihtml5-0.3.0.js"></script>
<script src="/Public/Admin/js/jquery-latest.js"></script>

<script src="/Public/Admin/js/bootstrap-wysihtml5-0.0.2.js"></script>
<!--<script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>-->
<script src="/Public/Admin/js/bootstrap.min.js"></script>
<script src="/Public/Admin/js/jquery-ui-1.10.2.custom.min.js"></script>
<!-- knob -->
<script src="/Public/Admin/js/jquery.knob.js"></script>
<!-- flot charts -->
<script src="/Public/Admin/js/jquery.flot.js"></script>
<script src="/Public/Admin/js/jquery.flot.stack.js"></script>
<script src="/Public/Admin/js/jquery.flot.resize.js"></script>
<!-- morrisjs -->
<script src="/Public/Admin/js/raphael-min.js"></script>
<script src="/Public/Admin/js/morris.min.js"></script>
<!-- call all plugins -->
<script src="/Public/Admin/js/theme.js"></script>

<script src="/Public/Admin/js/tools.js"></script>
<script src="/Public/Libs/confirm/jquery.confirm.js"></script>

<script src="/Public/Admin/js/jquery-latest.js"></script>
<script src="/Public/Admin/js/bootstrap.min.js"></script>
<script src="/Public/Admin/js/jquery.uniform.min.js"></script>
<script src="/Public/Admin/js/select2.min.js"></script>



<script type="text/javascript">
    $(function () {

        $(".select2").select2({
            placeholder: "请选择一个选项"
        });
    });

    function xyChange() {

        var x_id = $('#xy_id').val();

        $("#mojor_select>div>a>span").html("");
        var zySelector =  $('#zySelector');
        zySelector.html('');
        $.ajax({
            url:"<?php echo U('Depart/getZY');?>",
            data:{'x_id':x_id},
            type: "GET",
            dataType:"json",
            success: function(res){
               if(res.status ==  1){

                    for(var i=0;i<res.data.length;i++) {
                        zySelector.append($('<option value="'+res.data[i].id+'">' + res.data[i].name + '</option>'));
                    }
                }else{
                    console.log(res.msg);
                }
            }
        });
    }



    function edit() {
        var x_id = $('#xy_id').val();
        var z_id = $('#zySelector').val();
        var b_id = $('#bj_id').val();
        var bj_name = $('#bj_name').val();
        if ( x_id == "" || z_id == "" || bj_name ==""){
            $('#msg >small').html('二级学院或者专业名称或者班级不能为空!');
            $('#msg').show();
            return;
        }
        $.post('/admin.php/Depart/edit_bj',{x_id:x_id,z_id:z_id,b_id:b_id,bj_name:bj_name}, function (result) {
            var obj = eval('('+result+')');
            if (obj.result == "RESULT_OK"){
                window.location.href = obj.data;
            }else{
                $('#msg > small').html(obj.msg);
                $('#msg').show();
            }

        });

    }
</script>


</body>
</html>